//// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
//package com.linqingying.gitcode.pullrequest
//
//import com.intellij.openapi.components.Service
//import com.intellij.openapi.components.service
//import com.intellij.openapi.fileEditor.FileEditor
//import com.intellij.openapi.fileEditor.FileEditorPolicy
//import com.intellij.openapi.fileEditor.FileEditorProvider
//import com.intellij.openapi.progress.ProcessCanceledException
//import com.intellij.openapi.project.DumbAware
//import com.intellij.openapi.project.Project
//import com.intellij.openapi.vfs.VirtualFile
//import com.intellij.platform.util.coroutines.childScope
//import kotlinx.coroutines.CoroutineScope
//import kotlinx.coroutines.Dispatchers
//
//internal class GCPREditorProvider : FileEditorProvider, DumbAware {
//
//  override fun accept(project: Project, file: VirtualFile): Boolean =
//    file is GCPRTimelineVirtualFile && file.isValid
//
//  override fun createEditor(project: Project, file: VirtualFile): FileEditor {
//    file as GCPRTimelineVirtualFile
//    return project.service<GCPREditorProviderService>().createTimelineEditor(file)
//  }
//
//  override fun getEditorTypeId(): String = "GCPR"
//  override fun getPolicy(): FileEditorPolicy = FileEditorPolicy.HIDE_DEFAULT_EDITOR
//}
//
//@Service(Service.Level.PROJECT)
//private class GCPREditorProviderService(parentCs: CoroutineScope) {
//  private val cs = parentCs.childScope(Dispatchers.Main)
//
//  fun createTimelineEditor(file: GCPRTimelineVirtualFile): FileEditor {
//    val projectVm = file.findProjectVm() ?: throw ProcessCanceledException()
//    return GCPRTimelineFileEditor(cs, projectVm, file)
//  }
//}
